<template>
  <el-row>
    <el-col>
      <el-row :gutter="20">
        <!-- <el-col :span="2">
          <el-button class="dc_b" type="primary" round size="mini" @click="dc_click">导出</el-button>
        </el-col> -->
        <el-col :span="2">
          <el-select v-model="value" placeholder="走访状态" clearable @change="getSearch">
            <el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value">
            </el-option>
          </el-select>
        </el-col>
        <el-col :span="2">
          <el-select v-model="value2" placeholder="筛选镇街" clearable @change="getVisit" v-if="street_id">
            <el-option v-for="item in options2" :key="item.id" :label="item.name" :value="item.id">
            </el-option>
          </el-select>
        </el-col>
        <el-col :span="6" :offset="street_id ? 14 : 16">
          <el-input placeholder="关键词搜索" v-model="search" @change="change">
            <i slot="suffix" class="el-input__icon el-icon-search"></i>
          </el-input>
        </el-col>
      </el-row>
    </el-col>
    <el-col class="table_c">
      <el-table @row-click="tableclick" :header-cell-style="{ backgroundColor: '#f5f6f9' }" :data="tableData.list"
        style="width: 100%">
        <el-table-column prop="rank" label="排序" width="100">
        </el-table-column>
        <el-table-column prop="company_name" label="企业名称">
        </el-table-column>
        <el-table-column prop="label" label="走访状态" width="300">
          <template slot-scope="scope">
            <el-tag type="success" v-if="scope.row.label == 1">已走访</el-tag>
            <!-- <el-tag type="danger" v-if="scope.row.label == 2">未走访</el-tag> -->
            <!-- <el-tag type="danger" v-if="scope.row.label == 3">90天未走访</el-tag> -->
            <el-tag type="danger" v-if="scope.row.label == 4">180天未走访</el-tag>
            <!-- <el-tag type="danger" v-if="scope.row.label == 5">360天未走访进行筛选</el-tag> -->
          </template>
        </el-table-column>
        <el-table-column prop="" label="联系人/联系方式">
          <template slot-scope="scope">
            <span class="text_one">
              {{ scope.row.username }}
            </span>
            <span class="text_one">
              {{ scope.row.mobile }}
            </span>
          </template>
        </el-table-column>

        <el-table-column prop="num2" :label="tableData.date[1] + '年专利数量'">
        </el-table-column>
        <el-table-column prop="num1" :label="tableData.date[0] + '年专利数量'">

        </el-table-column>
        <el-table-column label="操作" width="140">
          <template slot-scope="scope">
            <el-button class="add_button" @click="handleClick(scope.row)" size="mini" round>添加到待走访</el-button>
          </template>
        </el-table-column>
      </el-table>
    </el-col>
  </el-row>
</template>

<script>
import { companyStreet,visitDetailtwo } from '@/api/newuser'

export default {
  components: {},
  props: {
    tableData: {
      type: Object,
      default: function () {
        return {}
      }
    }
  },

  data() {
    return {
      search: '',
      form: {
        region: '',
        date1: '',
        date2: '',
      },
      value: '',
      options: [{
        value: '0',
        label: '全部'
      }, {
        value: '1',
        label: '未走访'
      }, {
        value: '2',
        label: '已走访'
      },
      //  {
      //   value: '3',
      //   label: '90未走访'
      // }, 
      {
        value: '4',
        label: '180未走访'
      }],
      value2: '',
      options2: [],
      street_id: false
    };
  },
  mounted() {
    if (this.$store.state.user.com_id == 0 && this.$store.state.user.street_id == 0) {
      this.street_id = true
      companyStreet().then(res => {
        this.options2 = res;
        // console.log(res);
      })
    }
  },
  methods: {
    change() {
      this.$emit('change', this.search)
    },
    tableclick(row) {
      this.$router.push({
        path: '/workEnterprisevisit',
        query: {
          company_id: row.company_id,
          company_name: row.company_name,
        }
      })


      //判断是否有走访记录
      // visitDetailtwo({
      //   company_id: row.company_id
      // }).then(res => {
      //   // console.log(res);
      //   if (res.list.length == 0) {
      //     this.$router.push(
      //       {
      //         path: '/addWaitvisit',
      //         query: {
      //           company_name: row.company_name,
      //           company_id: row.company_id,
      //         }
      //       }
      //     )
      //   } else {
      //     this.$router.push({
      //       path: '/workEnterprisevisit',
      //       query: {
      //         company_id: row.company_id,
      //       }
      //     })
      //   }
      // })
    },
    getSearch(status) {
      this.$emit('getSearch', status);
    },
    getVisit(street_id) {
      this.$emit('getVisit', street_id);
    },
    onSubmit() {
      this.dialogVisible = false
      // console.log('submit!');
    },
    handleClick(row) {
      // console.log(row);
      this.$router.push(
        {
          path: '/addWaitvisit',
          query: {
            company_name: row.company_name,
            company_id: row.company_id,
          }
        }
      )
    },
    TabsClick() { },
    dc_click() {
    }
  },
};
</script>

<style scoped lang="less">
::v-deep input {
  border-radius: 30px;
  height: 30px;
  line-height: 30px;
}

.add_button {
  color: #3E7EF5;
  background-color: #ecf3ff;
  border: none;
  font-size: 14px;
}

::v-deep .el-input__icon {
  line-height: 38px;
  font-size: 16px;
}

.dc_b {
  /*padding: 7px 40px;*/
  width: 124px;
  height: 38px;
  background: #387DFF;
  border-radius: 19px;
  font-size: 16px;
}

.el-main {
  margin-right: 15px;
  border-radius: 5px;
  margin: 25px 30px 0 30px;
}

.table_c {
  margin-top: 15px;
}




@media (max-width: 1360px) {}

@media (max-width: 1280px) {}
</style>
